package com.f5.management.controller;

import com.f5.management.entity.Equipment;
import com.f5.management.entity.Toll;
import com.f5.management.service.EquipmentService;
import com.f5.management.service.TollService;
import com.f5.management.utils.PageResult;
import com.f5.management.utils.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.ParseException;
import java.util.List;

@RestController
@RequestMapping("/toll")
@CrossOrigin(origins = {"http://localhost:8080", "null"})
public class TollController {

    @Autowired
    private TollService tollService;

    @RequestMapping("/findByPage")
    public PageResult<List<Toll>> findByPage(int page, int size) {

        return tollService.findByPage(page, size);
    }
    @RequestMapping("/add")
    public ResponseResult<String> add(Toll toll) throws ParseException {

        return new ResponseResult<String>(tollService.add(toll));
    }
    @RequestMapping("/findCidByName")
    public  int findCidByName(String communityName){

        return tollService.findCidByName(communityName);
    }
    @RequestMapping("/findById")
    public  Toll findById(int id){

        return tollService.findById(id);
    }
    @RequestMapping("/updateInfo")
    public ResponseResult<String> updateInfo(Toll toll) {

        return new ResponseResult<String>(tollService.updateInfo(toll));

    }
    @RequestMapping("/delInfo")
    public ResponseResult<String> delInfo(int id) {

        return new ResponseResult<String>(tollService.delInfo(id));

    }
}
